import store,{addGoods,joinCart} from "./store";

/********************操作数据***************************************************/
store.subscribe(function(){
    console.log(store.getState());// {goods.js:[{id:xxx,goodsName:"笔记本",goodsPrice:1000}],cart:[]}
})
// 添加商品
store.dispatch(addGoods({goodsName:"笔记本",goodsPrice:1000}));
store.dispatch(addGoods({goodsName:"鼠标",goodsPrice:99}));
// 将商品放置到购入车
const {goodsList} = store.getState().goods;
store.dispatch(joinCart(goodsList[0]))
store.dispatch(joinCart(goodsList[1]))
store.dispatch(joinCart(goodsList[0]))
store.dispatch(joinCart(goodsList[0]))
